package com.wangshouyu.mp.pay.v3.transactions;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import com.wangshouyu.mp.pay.v3.common.request.BaseV3PayRequest;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2021年05月17日 09:29
 * @description 退款请求
 */
public class RefundRequest extends BaseV3PayRequest implements Serializable {

    /**
     * 交易订单id
     */
    @SerializedName(value = "transaction_id")
    @JsonProperty(value = "transaction_id")
    @JSONField(name = "transaction_id")
    private String transactionId;
    /**
     * 商户订单号
     */
    @SerializedName(value = "out_trade_no")
    @JsonProperty(value = "out_trade_no")
    @JSONField(name = "out_trade_no")
    private String outTradeNo;

    /**
     * 商户退款单号
     */
    @SerializedName(value = "out_refund_no")
    @JsonProperty(value = "out_refund_no")
    @JSONField(name = "out_refund_no")
    private String outRefundNo;

    /**
     * 退款原因
     */
    @SerializedName(value = "reason")
    @JsonProperty(value = "reason")
    @JSONField(name = "reason")
    private String reason;

    /**
     * 退款回调url
     */
    @SerializedName(value = "notify_url")
    @JsonProperty(value = "notify_url")
    @JSONField(name = "notify_url")
    private String notifyUrl;

    /**
     * 订单金额信息
     */
    @SerializedName(value = "amount")
    @JsonProperty(value = "amount")
    @JSONField(name = "amount")
    private RefundAmount amount;

    public String getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

    public String getOutTradeNo() {
        return outTradeNo;
    }

    public void setOutTradeNo(String outTradeNo) {
        this.outTradeNo = outTradeNo;
    }

    public String getOutRefundNo() {
        return outRefundNo;
    }

    public void setOutRefundNo(String outRefundNo) {
        this.outRefundNo = outRefundNo;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl) {
        this.notifyUrl = notifyUrl;
    }

    public RefundAmount getAmount() {
        return amount;
    }

    public void setAmount(RefundAmount amount) {
        this.amount = amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;
        RefundRequest that = (RefundRequest) o;
        return Objects.equals(transactionId, that.transactionId) && Objects.equals(outTradeNo, that.outTradeNo) && Objects.equals(outRefundNo, that.outRefundNo) && Objects.equals(reason, that.reason) && Objects.equals(notifyUrl, that.notifyUrl) && Objects.equals(amount, that.amount);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), transactionId, outTradeNo, outRefundNo, reason, notifyUrl, amount);
    }

    @Override
    public String toString() {
        return "RefundRequest{" +
                "transactionId='" + transactionId + '\'' +
                ", outTradeNo='" + outTradeNo + '\'' +
                ", outRefundNo='" + outRefundNo + '\'' +
                ", reason='" + reason + '\'' +
                ", notifyUrl='" + notifyUrl + '\'' +
                ", amount=" + amount +
                '}';
    }

}
